<template>
	<view class="page page-fill">
		<form @submit="formSubmitNickname">
			<view class="page-block" style="margin-top: 10px;">
				<input type="text" :value="globalUser.nickname" class="input" name="nickname" placeholder="请输入昵称" placeholder-class="graywords" maxlength="10"/>
			</view>
			
			<button type="primary" form-type="submit" class="submitBtn">提交</button>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				globalUser:{},
				userInfo:''
			}
		},
		methods: {
			formSubmitNickname(e){
				var me=this;
				var nickname=e.detail.value.nickname;
			}
		},
			
		onLoad(){
			var me=this;
			var globalUser=me.getGlobalUser('globalUser');
			me.globalUser=globalUser;
			
				uni.request({
					url: 'https://www.imovietrailer.com/superhero/user/modifyUserinfo?qq=lee57837906',
					data:{
						'userId':me.globalUser.id,
						'nickname':nickname,
					},
					header: {
						"headerUserId": me.globalUser.id,
						"headerUserToken":me.globalUser.userUniqueToken
					},
					method: 'POST',
					success: (res) => {
						var resDataStr=res.data;
						var resData=JSON.parse(resDataStr);
						if(resData.status==200){
							var userInfo=resData.data;
							uni.setStorageSync("globalUser",userInfo);
							uni.navigateBack({
								delta:1
							})
						}else if(resData.status==502||resData.status==500){
							uni.showToast({
								title:res.data.msg,
								duration:2000
							})
						}
						
					}
				});
		}
	}
</script>

<style>
	.page-fill{
		width: 100%;
		height: 100%;
		position: absolute;
	}
	.graywords{
		color: #EAEAEA;
	}
	.input{
		height: 80upx;
		line-height: 80upx;
		width: 500upx;
		margin-left: 40upx;
	}
	.submitBtn{
		width: 95%;
		margin-top: 40upx;
	}
</style>
